package com.hitqz.robot.biz.service.impl;

import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hitqz.robot.api.common.entity.Robot;
import com.hitqz.robot.api.dispatch.protocol.dto.RobotDto;
import com.hitqz.robot.biz.mapper.RobotMapper;
import com.hitqz.robot.biz.service.RobotService;
import com.hitqz.robot.netty.service.Send2ServerService;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

/**
 * @author xupkun
 * @date 2024/5/20
 */
@Service("robotService")
@RequiredArgsConstructor
public class RobotServiceImpl extends ServiceImpl<RobotMapper, Robot> implements RobotService {

    private final Send2ServerService send2ServerService;

    @Override
    public Robot getDefaultRobot() {
        return this.getById(1L);
    }

    @Override
    public void syncRobot() {
        Robot robot = this.getDefaultRobot();
        RobotDto robotDto = new RobotDto();
        BeanUtil.copyProperties(robot, robotDto, false);
        send2ServerService.syncRobotInfo(0, robotDto);
    }

}
